<template>
  <div class="new-music">
    <h2>最新音乐</h2>
    <div
      class="new-music-item"
      v-for="(item,index) in newMusic"
      :key="index"
      @click="itemClick(index)"
    >
      <div class="item-info">
        <div class="item-info-1">{{item.name}}</div>
        <div class="item-info-2">
          <i class="sghot"></i>
          {{item.song.artists[0].name}}
        </div>
      </div>
      <div class="item-player">
        <span class="sgchply"></span>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    newMusic: {
      type: Array,
      default() {
        return [];
      },
    },
  },
  methods: {
    itemClick(index) {
      this.$emit("newMusicClick", this.newMusic[index].id);
    },
  },
};
</script>

<style scoped>
.new-music h2 {
  position: relative;
  padding-left: 9px;
  margin-bottom: 14px;
  font-size: 17px;
  height: 20px;
  line-height: 20px;
  font-weight: 400;
  color: #333;
}
.new-music h2::after {
  position: absolute;
  content: "";
  background-color: #d33a31;
  width: 2px;
  height: 16px;
  left: 0;
  top: 50%;
  margin-top: -9px;
}
.new-music-item {
  display: flex;
  padding-left: 10px;
  height: 55px;
}
.item-info {
  padding: 6px 0;
  width: 0;
  flex: 1 1 auto;
}
.item-info-1 {
  font-size: 17px;
  height: 25px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  word-break: normal;
  color: #333;
}
.item-info-2 {
  height: 18px;
}
.sghot {
  display: inline-block;
  width: 12px;
  height: 8px;
  margin-right: 4px;
  background: url("https://s3.music.126.net/mobile-new/img/index_icon_2x.png?5207a28c3767992ca4bb6d4887c74880=")
    no-repeat;
  background-size: 166px 97px;
}
.item-player {
  width: 42px;
  padding: 0 10px;
  display: flex;
  align-items: center;
}
.sgchply {
  display: inline-block;
  width: 22px;
  height: 22px;
  background: url("https://s3.music.126.net/mobile-new/img/index_icon_2x.png?5207a28c3767992ca4bb6d4887c74880=")
    no-repeat;
  background-size: 166px 97px;
  background-position: -24px 0;
}
</style>